<template>
   <div class="after-sale-reason views-container">
        <div class="wlm-table">
            <div class="wlm-table-hearder-btn">
                  <router-link class="wlm-text" tag="span" :to="{path:'/application/treasureAdd'}">
                            <el-button size="small" type="primary">添加活动</el-button>
            </router-link>
            </div>
              <div class="wlm-table-content">
                    <el-table   style="width: 100%" :ref="tableFormatData.treasure.key"
                    :data="tableFormatData.treasure.tableData"
                    @selection-change="handleSelectionChange">
                        <!-- <el-table-column type="selection" width="55">
                        </el-table-column> -->
                        <el-table-column prop="date" label="活动名称" >
                            <template slot-scope="scope">
                                 <span>{{scope.row.title}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="活动状态" >
                            <template slot-scope="scope">
                                <el-tag type="danger" v-if="scope.row.status==0">未开始</el-tag>
                                <el-tag type="success" v-if="scope.row.status==1">已开始</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="助力次数" >
                            <template slot-scope="scope">
                                 <span>{{scope.row.assist_time==null?0:scope.row.assist_time}}</span>
                            </template>
                        </el-table-column>
                         <el-table-column prop="date" label="助力人数" >
                            <template slot-scope="scope">
                                 <span>{{scope.row.assist_user==null?0:scope.row.assist_user}}</span>
                            </template>
                        </el-table-column>
                         <el-table-column prop="date" label="成功人数" >
                            <template slot-scope="scope">
                                 <span>{{scope.row.assist_success==null?0:scope.row.assist_success}}</span>
                            </template>
                        </el-table-column>
                         <el-table-column prop="date" label="收入" >
                            <template slot-scope="scope">
                                <span>{{scope.row.assist_shouru==null?0:scope.row.assist_shouru}}</span>
                            </template>
                        </el-table-column>
                         <!-- <el-table-column prop="date" label="老用户是否可以助力" >
                            <template slot-scope="scope">
                            </template>
                        </el-table-column> -->
                         <el-table-column prop="date" label="操作" >
                            <template slot-scope="scope">
                                <div class="operation-group">
                                   <router-link class="wlm-text" tag="span" :to="{path:'/application/treasureDetails', query:{id:scope.row.id}}">
                                        <el-button class="wlm-text" type="text">活动详情</el-button>
                                    </router-link>
                                    <div class="btn-line"></div>
                                   <router-link class="wlm-text" tag="a" target="_blank" :to="{path:'/application/treasureAdd', query:{
                                       id:scope.row.id,
                                       store_user_id:$route.query.store_user_id?$route.query.store_user_id:'',
                                       h_aid:$route.query.h_aid?$route.query.h_aid:'',
                                       }}">
                                        <el-button type="text">编辑</el-button>
                                    </router-link>
                                  <div class="btn-line"></div>
                                  <el-button class="wlm-text" type="text" @click="delbtn(scope.row.id)">删除</el-button>
                                </div>
                            </template>
                        </el-table-column>
                    </el-table>
                     <div class="pagination-content flex-row flex-justify-e flex-align-c">
          <el-pagination
            :disabled="!hasTableData"
            @size-change="listPageChange"
            @current-change="listPageChange"
            :current-page.sync="tableFormatData.treasure.pagination.page"
            :page-sizes="tableFormatData.treasure.pagination.pagesizes"
            :page-size.sync="tableFormatData.treasure.pagination.list_rows"
            layout="total, sizes, prev, pager, next, jumper"
            :total="hasTableData?tableFormatData.treasure.pagination.total : 0"
          >
          </el-pagination>
        </div>
            </div>
        </div>
   </div>
</template>
<script>
import {
 assistList,
 deleteAssist
} from '@/api/application'
import mixins from '@/mixins/mixins'
export default {
     mixins: [mixins.getters('Table')],
     name:'treasure',
     data(){
         return{
              tableFormatData: {
                current: 'treasure',
                treasure: {
                key: 'treasure',
                api: {
                    getList: assistList
                },
                tableData: [],
                files: {
                    // ids: [],
                    // checkall: '0',
                    // live_state: 'all',
                    // id:'',
                },
                pagination: {
                    page: 1,
                    list_rows: 10,
                    pagesizes: [10, 20, 50],
                    total: 0
                }
                }
            }
        }
     },
     created(){

     },
     methods:{
         delbtn(id){
              this.$confirm('此操作将永久删除该活动, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                     deleteAssist({id:id}).then(res=>{
                         if(res.data.code==1){
                             this.$message.success(res.data.msg)
                             this.filesSerch()
                         }
             })
                }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });          
                });
            
         }
        },
}
</script>